package com.dzm.xgb.core.controller.api;


import com.dzm.common.result.R;
import com.dzm.common.util.JwtUtils;
import com.dzm.xgb.core.pojo.entity.Lend;
import com.dzm.xgb.core.service.LendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 标的准备表 前端控制器
 * </p>
 *
 * @author Dzm
 * @since 2024-08-27
 */

@RestController
@RequestMapping("/api/core/lend")
public class LendController {

    @Autowired
    private LendService lendService;

    @GetMapping("/list")
    public R list() {
        List<Lend> list = lendService.findAll();

        return R.ok().data("list", list);
    }

    @GetMapping("/show/{id}")
    public R show(@PathVariable("id")Long id){
        Map<String, Object> map = lendService.show(id);

        return R.ok().data("lendDetail", map);
    }

    @GetMapping("/getInterestCount/{invest}/{yearRate}/{totalmonth}/{returnMethod}")
    public R getInterestCount(@PathVariable BigDecimal invest,
                              @PathVariable BigDecimal yearRate,
                              @PathVariable Integer totalmonth,
                              @PathVariable Integer returnMethod) {
        BigDecimal interestCount = lendService.getInterestCount(invest, yearRate, totalmonth, returnMethod);

        return R.ok().data("interestCount", interestCount);
    }

}

